<%@page contentType="text/html"%>  
<%@page pageEncoding="UTF-8"%>  

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>  
<%@taglib uri="http://richfaces.org/a4j" prefix="a4j"%>  
<%@taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   
"http://www.w3.org/TR/html4/loose.dtd">  
<html>
    <head>
        <title>Venda</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="cache-control" content="no-store">
        <meta http-equiv="expires" content="0">
    </head>
    <style type="text/css"><!--@import url("../_css/style.css");--></style>
    <body>
        <f:view>
            <t:saveState id="_bean" value="#{VendaBean}" />
            <a4j:form id="VendaPesq" status="modalStatus">
                <rich:simpleTogglePanel switchType="client" label="Venda" width="95%">
                    <t:panelGrid columns="4">
                        <t:column width="15%">
                            <h:outputLabel value="Período entre"/>
                        </t:column>
                        <t:column width="35%">
                            <rich:calendar id="dataCadastroIni" popup="true" datePattern="dd/MM/yyyy" inputSize="7" enableManualInput="false" value="#{VendaBean.dataCadastroIni}"/>
                            &nbsp;e&nbsp;
                            <rich:calendar id="dataCadastroFim" popup="true" datePattern="dd/MM/yyyy" inputSize="7" enableManualInput="false" value="#{VendaBean.dataCadastroFim}"/>
                        </t:column>
                        <t:column>&nbsp;</t:column>
                        <t:column>&nbsp;</t:column>

                        <t:column><h:commandButton value="Pesquisar" action="#{VendaBean.pesquisar}"/>&nbsp;&nbsp;</t:column>
                        <t:column><h:commandButton value="Novo" action="#{VendaBean.incluir}"/>&nbsp;&nbsp;</t:column>
                        <t:column>&nbsp;</t:column>
                        <t:column>&nbsp;</t:column>
                    </t:panelGrid>
                </rich:simpleTogglePanel>
                
                <rich:dataTable id="tblVendas" value="#{VendaBean.listaVendas}" var="list"
                                width="95%" columnClasses="center" rows="50" reRender="ds">
                    <rich:column width="40px">
                        <f:facet name="header">
                            <h:outputText value="Cód"/>
                        </f:facet>
                        <h:outputText value="#{list.id}"/>
                    </rich:column>
                    <rich:column style="text-align:center;">
                        <f:facet name="header">
                            <h:outputText value="Data Cadastro"/>
                        </f:facet>
                        <h:outputText value="#{list.dataCadastro}"/>
                    </rich:column>
                    <rich:column sortBy="#{list.valor}" style="text-align:right;">
                        <f:facet name="header">
                            <h:outputText value="Valor"/>
                        </f:facet>
                        <h:outputText value="#{list.valor}"><f:convertNumber pattern="#,##0.00"/></h:outputText>
                    </rich:column>
                    <rich:column width="50px">
                        <f:facet name="header">
                            <h:outputText value="Ações"/>
                        </f:facet>
                        <h:commandButton image="../_images/btn_detalhar.png" title="Imprimir Venda" binding="#{VendaBean.btnImprimir}" value="#{list.id}"  action="#{VendaBean.imprimir}"/>&nbsp;
                        <h:commandButton image="../_images/btn_excluir.gif" title="Cancelar Venda" binding="#{VendaBean.btnExcluir}" value="#{list.id}" action="#{VendaBean.cancelar}" onclick="if (confirm('Confirma cancelar Venda cód. #{list.id}')) {return true;}else{return false;} "/>
                    </rich:column>

                    <f:facet name="footer">
                        <rich:datascroller id="ds"></rich:datascroller>
                    </f:facet>
                    
                </rich:dataTable>
                <a4j:status id="modalStatus" onstart="Richfaces.showModalPanel('ajaxLoadingModalBox')"
                onstop="Richfaces.hideModalPanel('ajaxLoadingModalBox')" />
            </a4j:form>
        </f:view>
    </body>
</html>